// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database();
// 云函数入口函数
// 判断商品是否被收藏
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()

  let goodsId = event.goodsId;
  let result = await db.collection("collect").where({
    goodsId,
    openid:wxContext.OPENID
  }).get();

  let status = false;
  if(result.data.length){
    status = true;
  }
  return {
    code:200,
    status
  }
}